package com.example.demo.model.admin.admin.controler;

import com.example.demo.Results.Result;
import com.example.demo.model.admin.admin.entity.EditPassReq;
import com.example.demo.model.admin.admin.service.ShopAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 后台修改
 */
@Api(tags = "后台登录")
@Slf4j
@RestController
@RequestMapping("/admin/shopAdminPage")
public class ShopAdminPageResource {

    @Autowired
    private ShopAdminService shopAdminService;

    @GetMapping("/editPass")
    @ApiOperation(value = "管理员修改密码页面")
    public ModelAndView toEdit(){
        return shopAdminService.editPass();
    }

    @PostMapping("/doEditPass")
    @ApiOperation("修改密码")
    public Result doEdit(HttpServletRequest request, EditPassReq editPass){

        return shopAdminService.doEditPass(request,editPass);
    }
}
